package com.aaa.backsystem.service.impl;


import com.aaa.backsystem.entity.EchartsDataBo;
import com.aaa.backsystem.entity.Sale;
import com.aaa.backsystem.dao.SaleDao;
import com.aaa.backsystem.service.SaleService;
import com.aaa.backsystem.util.EchartUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author gyc
 * @since 2020-07-23
 */
@Service
public class SaleServiceImpl extends ServiceImpl<SaleDao, Sale> implements SaleService {

    @Autowired
    private SaleDao saleDao;

    @Override
    public List<EchartsDataBo> findBathSale(String year,Integer userId) {
        //获取数据
        List<Sale> sales = saleDao.OilMonthlySales(year,userId);

        //调用echart工具类
        List<EchartsDataBo> echartsDataBos = EchartUtil.findName(sales);

        return echartsDataBos;
    }

    @Override
    public List<Sale> findBuyYear(Integer userId) {
        return saleDao.findBuyYear(userId);
    }

    @Override
    public  List<EchartsDataBo> OilMonthlySales(String year) {
        //获取数据
        List<Sale> sales = saleDao.OilMonthlySales(year,null);

        //调用echart工具类
        List<EchartsDataBo> echartsDataBos = EchartUtil.findName(sales);

        return echartsDataBos;
    }
}
